<%@ page language="java" contentType="text/html; charset=UTF-8"
  pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
  content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="../css/pintuer.css">
<link rel="stylesheet" href="../css/admin.css">
<script src="../js/jquery.js"></script>
<script src="../js/pintuer.js"></script>
<!-- 引入layui的样式文件 -->
<link rel="stylesheet" type="text/css" href="../layui/css/layui.css" />
<!-- 引入layui的脚本文件 -->
<script src="../layui/layui.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
  <div class="panel admin-panel">
    <div class="panel-head">
      <strong><span class="icon-key"></span> 修改会员密码</strong>
    </div>
    <div class="body-content">
      <form method="post" id="form" class="form-x" action="">
        <div class="form-group">
          <div class="label">
            <label for="sitename">管理员帐号：</label>
          </div>
          <div class="field">
            <label style="line-height: 33px;">${username }</label>
          </div>
        </div>
        <div class="form-group">
          <div class="label">
            <label for="sitename">原始密码：</label>
          </div>
          <div class="field">
            <input type="password" class="input w50" id="mpass" name="mpass"
              size="50" placeholder="请输入原始密码" data-validate="required:请输入原始密码" />
          </div>
        </div>
        <div class="form-group">
          <div class="label">
            <label for="sitename">新密码：</label>
          </div>
          <div class="field">
            <input type="password" class="input w50" id="newpass"
              name="newpass" size="50" placeholder="请输入新密码"
              data-validate="required:请输入新密码,length#>=5:新密码不能小于5位" />
          </div>
        </div>
        <div class="form-group">
          <div class="label">
            <label for="sitename">确认新密码：</label>
          </div>
          <div class="field">
            <input type="password" class="input w50" id="renewpass"
              name="renewpass" size="50" placeholder="请再次输入新密码"
              data-validate="required:请再次输入新密码,repeat#newpass:两次输入的密码不一致" />
          </div>
        </div>

        <div class="form-group">
          <div class="label">
            <label></label>
          </div>
          <div class="field">
            <button class="button bg-main icon-check-square-o" lay-submit
              lay-filter="subBtnUpdate">提交</button>
          </div>
        </div>
      </form>
    </div>
  </div>
  
  <!--MD5加密-->
  <script src="https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.js"></script>
  <script>
    
    layui.use(['form','layer'], function() {
      var form = layui.form;
      var $ = layui.$;
      var layer = layui.layer;

      //表单提交
      form.on('submit(subBtnUpdate)', function(data) {
        data.field.mpass = md5($("#mpass").val());
        data.field.newpass = md5($("#newpass").val());
        data.field.renewpass = md5($("#renewpass").val());
        if ($("#mpass").val() && $("#newpass").val()
            && $("#renewpass").val()) {
          var url = "UserServletAdmin?method=updateUserPwd";//请求地址
          
          //ajax请求服务器,判断结果
          $.post(url, data.field, function(res) {
            console.log(res);
            if (res.code == 0) {
              layer.msg(res.msg, {
                time : 1000
              }, function() {
                layer.closeAll();//关闭所有窗口
              })
            } else {
              layer.msg(res.msg, {
                time : 1000
              })
            }
          }, "json")
        } else {
          layer.msg("请输入框内的值", {
            time : 1000
          });
        }
        return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。

      });

    });
  </script>


</body>
</html>
